package com.usernet.product.server;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.usernet.product.dao.PhotoDao;
import com.usernet.product.entity.Photo;

public class PhotoService {

	private PhotoDao photoDao = new PhotoDao();

	/**
	 * 获取软件截图[type=10]
	 */
	public String initPhoto(HttpServletRequest request) {
		String ret = null;
		try {
			String softId = request.getParameter("softId");
			int id = Integer.parseInt(softId);
			List<Photo> list = photoDao.getAllBySoftId(id);
			StringBuffer buf = new StringBuffer();
			buf.append("[");
			for (int i = 0; i < list.size(); i++) {
				Photo photo = list.get(i);
				buf.append("\"");
				buf.append(photo.getPhoto());
				buf.append("\"");
				if (i < list.size() - 1) {
					buf.append(",");
				}
			}
			buf.append("]");
			ret = MarketUtils.getResJson(buf.toString());
		} catch (Exception ex) {
			ex.printStackTrace();
			ret = MarketUtils.getThrowJson();
		}
		return ret;
	}
}
